Skip to content

fix(bin): count Jev transport failures in the timeout streak instead of a day pause - #64

Merged
alandomio merged 3 commits into
mainfrom
fm/jev-transport-backoff
Oct 20, 2026
Merged

alandomio merged 3 commits into
mainfrom
fm/jev-transport-backoff

Conversation

@alandomio

Copy link
Copy Markdown
Owner

Intent

Fix bin/fm-jev.sh so Jev shadow wake triage no longer pauses classification until midnight on any api-error. On 16/10 a single transient transport failure (curl exit 6, could not resolve host) disabled classification for the rest of the day. Treat transport-level failures (curl network exits such as 6, 7, 28, 35, 52, 56, i.e. no HTTP response received) the same way timeouts are handled: count them in the existing timeout streak and use the existing timed pause that doubles per repeat and never passes midnight, instead of the day-long api-error pause. Keep the day-long pause for genuine API errors that come back as an HTTP response (auth failure, 4xx/5xx, malformed response, missing usage.cost), and leave the spend cap untouched. Acceptance: colocated tests in tests/fm-jev.test.sh cover a single curl exit 6 (no day pause, streak 1), three in a row (timed pause), and an HTTP API error (day pause as today); docs/configuration.md 'Jev shadow wake triage' and the script header describe the new rule; shellcheck clean. Delivery mode no-mistakes.

What Changed

  • bin/fm-jev.sh: when curl fails with no HTTP response (DNS, connection or reset errors), Jev now adds one to the timeout streak (jev_timeout_note) instead of pausing OpenRouter classification for the rest of the day. This applies to both backends, so repeated transport failures now lead to the same timed pause as timeouts: it doubles each time it repeats and never runs past midnight. API errors that come back as an HTTP response, responses missing usage.cost, and the spend cap still pause until the next day, as before.
  • The script header, the state-file comment and the "Jev shadow wake triage" section of docs/configuration.md now describe this rule.
  • tests/fm-jev.test.sh: a new test checks that a single curl exit 6 (DNS failure) only logs api-error and sets the streak to 1, with no day pause.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The change is small: transport failures now go to the existing timeout-streak path, and the fix round only added a fake-curl mode that exits 6, as the user asked.

Testing

I ran tests/fm-jev.test.sh and every case passed, including the new transport test and the existing HTTP and missing-cost day-pause test. The new transport test covers a single curl exit 6 (no day pause, streak 1 of 3) and three refused connections in a row (timed pause, no further calls). To confirm it is a real regression test, I swapped in the base commit's script: the new case fails there with 'one transport error paused Jev', and passes with the fix. Logs are saved as evidence, and the worktree is clean.

Evidence: Jev tests with the fix (all pass)

Source: Jev tests with the fix (all pass)

ok - off by default: an ambient OPENROUTER_API_KEY neither logs nor calls the network
ok - a STATE other than the key home's own state never enables Jev
ok - shadow mode logs presentation, answer and acknowledgement without changing the drain
ok - only the masked reason and last status line are sent; the key stays off argv and disk
ok - config/jev-timeout overrides the 5 second default and invalid values keep it
ok - one timeout skips only that wake and does not pause Jev
ok - consecutive timeouts pause Jev for 60 minutes, reported by status and report
ok - config/jev-timeout-streak and config/jev-timeout-pause configure the pause rule and invalid values keep the defaults
ok - a successful classification resets the timeout streak
ok - a timeout pause expires by itself, repeat pauses back off, and none outlasts the day
ok - a legacy disabled file is read safely: old timeout records resume, other day pauses hold
ok - entering any pause appends one check wake with the reason and the pause-until time
ok - a resume wake follows only the first successful classification after an announced pause, once
ok - pause-state prints one line while paused and nothing otherwise
ok - HTTP errors and a missing cost pause Jev until the next day
ok - transport errors count in the timeout streak and start the timed pause, never a day pause
ok - the daily spend cap stops requests and pauses Jev until the next day
ok - config/jev-endpoint selects the local backend over an OPENROUTER_API_KEY, needs no key, and records the answering model
ok - a native status uncertain/insufficient_evidence answer (null choice) classifies as doubt, never as an error
ok - config/jev-timeout also overrides the local backend's request timeout
ok - the local endpoint and load ceiling are read from the home's own config/, the same place that selected the backend
ok - a whitespace-only config/jev-endpoint does not select the local backend
ok - a local response with no usage.cost classifies normally instead of erroring
ok - a non-loopback or path-carrying config/jev-endpoint is refused, never dialed, and pauses Jev
ok - a 1-minute load average at or above config/jev-max-load skips only that wake; a later reading below it classifies again
ok - a local timeout skips the rest of that drain and an API/transport error only its row, each logged with the reason; the next drain tries again with no day pause, unlike OpenRouter
ok - the local backend pauses for a short while only after consecutive timeouts
ok - status names the active backend, its endpoint or spend, and (for local) its load ceiling
ok - the drain returns immediately while a slow Jev request runs detached
ok - hooks record steers, decisions and how a turn ended, never its text
ok - only sends firstmate itself makes count as steers; FM_JEV_OBSERVE=0 senders record nothing
ok - the report credits named actions to their task's open wakes across drains and shares the rest
ok - unacknowledged and pre-window wakes stay open, so their steers never spill onto unrelated wakes
ok - the report computes agreement, wrongly absorbable wakes, go-live criteria and doubtful cases
ok - absorption off by default: no network call, no digest, absorb-try refuses
ok - absorption refuses any backend but local, even when requested
ok - requested absorption without a met gate or an override never dials the classifier
ok - a captain override skips the go-live gate and records a masked digest entry
ok - config/jev-absorb-threshold below 0.9 refuses absorption outright
ok - any doubt or below-threshold confidence falls through without a digest entry
ok - a task with an open decision is never absorbed
ok - a secondmate's status signal is never absorbed
ok - only a working:/paused: verb is ever eligible for absorption
ok - the deterministic veto refuses terminal statuses, check/heartbeat/merge reasons, and unread notes before any model call
ok - absorb-gate reports classified/scored/agreement/wrongly-absorbable and the sample-gated go-live verdict
ok - an absorbed wake surfaces exactly once with the next drain and never repeats
ok - the drain tags each digest entry via jev or via rule, defaulting to jev when the field is absent
ok - the digest is held while away mode drains and surfaces with the first drain after return
ok - a malformed digest line never hides later entries, and a partial line waits until complete
Evidence: Same tests against the base script (new case fails: one transport error paused Jev)

Source: Same tests against the base script (new case fails: one transport error paused Jev)

ok - off by default: an ambient OPENROUTER_API_KEY neither logs nor calls the network
ok - a STATE other than the key home's own state never enables Jev
ok - shadow mode logs presentation, answer and acknowledgement without changing the drain
ok - only the masked reason and last status line are sent; the key stays off argv and disk
ok - config/jev-timeout overrides the 5 second default and invalid values keep it
ok - one timeout skips only that wake and does not pause Jev
ok - consecutive timeouts pause Jev for 60 minutes, reported by status and report
ok - config/jev-timeout-streak and config/jev-timeout-pause configure the pause rule and invalid values keep the defaults
ok - a successful classification resets the timeout streak
ok - a timeout pause expires by itself, repeat pauses back off, and none outlasts the day
ok - a legacy disabled file is read safely: old timeout records resume, other day pauses hold
ok - entering any pause appends one check wake with the reason and the pause-until time
ok - a resume wake follows only the first successful classification after an announced pause, once
ok - pause-state prints one line while paused and nothing otherwise
ok - HTTP errors and a missing cost pause Jev until the next day
not ok - one transport error paused Jev

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 2 issues found → auto-fixed ✅
  • ℹ️ tests/fm-jev.test.sh:468 - The intent asks for a test of "a single curl exit 6 (no day pause, streak 1)", but the new test uses the fake curl's refused mode, which exits 7 (line 64). The fix sends every nonzero curl exit other than 28 down the same path, so exit 7 shows the same behavior. Even so, the 16/10 case (exit 6, could not resolve host) is not reproduced literally. Suggested fix: add a fake-curl mode that exits 6 (e.g. dns) exit 6 ;;) and use it in the single-failure case.
  • ℹ️ bin/fm-jev.sh:705 - Every nonzero curl exit other than 28 now counts toward the timeout streak. That includes exits that are not network failures, such as 23 (write error) or 26 (read error) from local temp files. These used to start a day pause and now get the timed pause instead. This is within the intent's "no HTTP response received" wording and is low impact. The same rule also now applies a timed pause to local-backend transport failures after N in a row; the docs cover this with "on either backend".

🔧 Fix: Test single curl exit 6 DNS failure in Jev
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • bash tests/fm-jev.test.sh (full colocated Jev test file, rc=0)
  • Regression check: ran the same tests against the base commit's bin/fm-jev.sh (18ed09c). The new case fails there with 'not ok - one transport error paused Jev'. The fixed script was restored afterwards.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@alandomio
alandomio merged commit 82a16d9 into main Oct 20, 2026
alandomio pushed a commit that referenced this pull request Oct 20, 2026
Conflicts resolved keeping both sides:
- bin/fm-brief.sh: upstream's shared infra rule, wait block and inbox
  section kept; the Haiku subagent section from #66 added after them.
- bin/fm-spawn.sh: --teleport from #65 ported onto upstream's
  record-backed launch brief; the arrival note is published as the
  launch record and the Claude launch resumes the teleported session.
- bin/fm-supervise-daemon.sh: wedge alarm helpers live in
  bin/fm-alert-lib.sh (#65); they were unchanged on our side since the
  merge base, so nothing is lost. Upstream's delivery-failure fields kept.
- tests/fm-teleport.test.sh: covers the teleported Claude launch on the
  record-backed brief path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant